package com.itnoob.controller;

import com.itnoob.domain.Article;
import com.itnoob.service.ReviewArticleService;
import com.itnoob.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhoujun
 * @date 2025/3/18 21:12
 */
@RestController
public class ArticleController {

    @Autowired
    private ReviewArticleService reviewArticleService;

    /**
     * {
     *     "content":"测试文章内容,,,,ss",
     *     "approved":false,
     *     "reViewers":"BASE,IMAGE"
     * }
     * @param article
     * @return
     */
    @PostMapping("/articles/review")
    @ResponseBody
    public ResponseEntity<String> reviewArticle(@RequestBody Article article){
        Result result = reviewArticleService.reviewArticle(article);

        if (result.isApproved()){
            return  ResponseEntity.ok("文章审核通过");
        }else {
            return ResponseEntity.ok("文章审核未通过"+ result.getMsg());
        }
    }
}
